namespace NBox.Service.Logging
{
	using System;
	using System.IO;

	[Serializable]
	public abstract class AbstractLoggerFactory : MarshalByRefObject, ILoggerFactory
	{
		public virtual ILogger Create(Type type)
		{
			if (type == null) throw new ArgumentNullException("type");

			return Create(type.FullName);
		}

		public virtual ILogger Create(Type type, LoggerLevel level)
		{
			if (type == null) throw new ArgumentNullException("type");

			return Create(type.FullName, level);
		}

		public abstract ILogger Create(String name);

		public abstract ILogger Create(String name, LoggerLevel level);

		/// <summary>
		/// Gets the configuration file.
		/// </summary>
		/// <param name="filename">i.e. log4net.config</param>
		/// <returns></returns>
		protected FileInfo GetConfigFile(string filename)
		{
			FileInfo result;

			if (Path.IsPathRooted(filename))
			{
				result = new FileInfo(filename);
			}
			else
			{
				result = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename));
			}

			return result;
		}
	}
}